package JDBC;



import java.sql.*;



public class JDBCDemo5 {
    public static void main(String[] args) throws Exception {
        //DBUtil:SQL数据库链接驱动
    Connection conn =DBUtil.getConnection();

    //Statement是给数据库建立链接，给传输具体内容，搭建的一个发射平台。
    Statement state =conn.createStatement();
    //String sql="";是发射具体内容
    String sql="SELECT id,name,salary,title FROM teacher ";
    //执行并返回结果
    ResultSet rs = state.executeQuery(sql);

    while (rs.next()){
        int id=rs.getInt("id");
        String name=rs.getString("name");
        double salary=rs.getDouble("salary");
        String title=rs.getString("title");
        System.out.println(id+","+name+","+salary+","+title);
    }

    conn.close();

    }
}
